<template>
	<view class="container">
		<!-- 用户信息卡片 -->
		<view class="user-card">
			<view class="avatar-wrapper">
				<image class="avatar" src="/static/default-avatar.png" mode="aspectFill"></image>
			</view>
			<view class="user-info">
				<text class="username">游客</text>
				<text class="user-id">ID: 888888</text>
			</view>
			<button class="login-btn" @tap="login" v-if="!isLoggedIn">登录/注册</button>
		</view>
		
		<!-- 功能菜单 -->
		<view class="menu-list">
			<view class="menu-item" @tap="navigateTo('/pages/my/orders')">
				<view class="menu-icon">📋</view>
				<text class="menu-text">我的订单</text>
				<text class="menu-arrow">></text>
			</view>
			<view class="menu-item" @tap="navigateTo('/pages/my/wallet')">
				<view class="menu-icon">👛</view>
				<text class="menu-text">我的钱包</text>
				<text class="menu-arrow">></text>
			</view>
			<view class="menu-item" @tap="navigateTo('/pages/my/favorite')">
				<view class="menu-icon">⭐</view>
				<text class="menu-text">收藏线路</text>
				<text class="menu-arrow">></text>
			</view>
		</view>
		
		<!-- 最近订单 -->
		<view class="recent-orders">
			<view class="section-title">最近订单</view>
			<view class="order-list">
				<view class="order-item" v-for="(order, index) in recentOrders" :key="index">
					<view class="order-header">
						<text class="order-number">订单号：{{order.orderNo}}</text>
						<text class="order-status" :class="order.status">{{order.statusText}}</text>
					</view>
					<view class="order-content">
						<view class="route-info">
							<text class="route-number">{{order.routeNumber}}</text>
							<text class="route-name">{{order.routeName}}</text>
						</view>
						<view class="order-detail">
							<text class="order-time">{{order.time}}</text>
							<text class="order-price">￥{{order.price}}</text>
						</view>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
export default {
	data() {
		return {
			isLoggedIn: false,
			recentOrders: [
				{
					orderNo: 'O2024032001',
					status: 'completed',
					statusText: '已完成',
					routeNumber: '101路',
					routeName: '火车站 → 汽车站',
					time: '2024-03-20 14:30',
					price: '2.00'
				},
				{
					orderNo: 'O2024031902',
					status: 'pending',
					statusText: '待使用',
					routeNumber: '201路',
					routeName: '大学城 → 市中心',
					time: '2024-03-19 09:15',
					price: '2.00'
				}
			]
		}
	},
	methods: {
		login() {
			uni.navigateTo({
				url: '/pages/login/login'
			})
		},
		navigateTo(url) {
			uni.navigateTo({
				url
			})
		}
	}
}
</script>

<style lang="scss">
.container {
	padding: 20rpx;
	background: #f5f5f5;
	min-height: 100vh;
}

.user-card {
	background: #fff;
	padding: 30rpx;
	border-radius: 20rpx;
	display: flex;
	align-items: center;
	margin-bottom: 30rpx;
	
	.avatar-wrapper {
		width: 120rpx;
		height: 120rpx;
		border-radius: 60rpx;
		overflow: hidden;
		margin-right: 30rpx;
	}
	
	.avatar {
		width: 100%;
		height: 100%;
	}
	
	.user-info {
		flex: 1;
		
		.username {
			font-size: 36rpx;
			font-weight: bold;
			margin-bottom: 10rpx;
			display: block;
		}
		
		.user-id {
			font-size: 24rpx;
			color: #999;
		}
	}
	
	.login-btn {
		background: #3cc51f;
		color: #fff;
		font-size: 28rpx;
		padding: 10rpx 30rpx;
		border-radius: 30rpx;
	}
}

.menu-list {
	background: #fff;
	border-radius: 20rpx;
	margin-bottom: 30rpx;
	
	.menu-item {
		display: flex;
		align-items: center;
		padding: 30rpx;
		border-bottom: 1rpx solid #f5f5f5;
		
		&:last-child {
			border-bottom: none;
		}
		
		.menu-icon {
			margin-right: 20rpx;
			font-size: 40rpx;
		}
		
		.menu-text {
			flex: 1;
			font-size: 28rpx;
		}
		
		.menu-arrow {
			color: #999;
			font-size: 28rpx;
		}
	}
}

.recent-orders {
	background: #fff;
	border-radius: 20rpx;
	padding: 30rpx;
	
	.section-title {
		font-size: 32rpx;
		font-weight: bold;
		margin-bottom: 20rpx;
	}
	
	.order-item {
		border-bottom: 1rpx solid #f5f5f5;
		padding: 20rpx 0;
		
		&:last-child {
			border-bottom: none;
		}
		
		.order-header {
			display: flex;
			justify-content: space-between;
			margin-bottom: 10rpx;
			
			.order-number {
				font-size: 24rpx;
				color: #999;
			}
			
			.order-status {
				font-size: 24rpx;
				
				&.completed {
					color: #3cc51f;
				}
				
				&.pending {
					color: #f56c6c;
				}
			}
		}
		
		.order-content {
			.route-info {
				margin-bottom: 10rpx;
				
				.route-number {
					font-size: 28rpx;
					font-weight: bold;
					margin-right: 20rpx;
				}
				
				.route-name {
					font-size: 28rpx;
					color: #666;
				}
			}
			
			.order-detail {
				display: flex;
				justify-content: space-between;
				
				.order-time {
					font-size: 24rpx;
					color: #999;
				}
				
				.order-price {
					font-size: 28rpx;
					color: #f56c6c;
				}
			}
		}
	}
}
</style> 